/**
 * @program: pettyloan
 * @ClassName QuartzConfig
 * @author: 汪江
 * @create: 2022-12-10 17:32
 **/
package com.wn.pettyloan.config;


import com.wn.pettyloan.quartz.UpdatRepayState;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class QuartzConfig {
    @Bean
    public JobDetail jobDetail(){
        //指定任务描述具体的实现类
        return JobBuilder.newJob(UpdatRepayState.class)
                //指定任务名称
                .withIdentity("修改还款状态","RepayGroup")
                //指定任务描述
                .withDescription("任务描述：修改还款记录的状态为逾期")
                //开户持久化存储
                .storeDurably(true)
                .build();
    }
    @Bean
    public Trigger trigger(){
        //创建触发器
        return TriggerBuilder.newTrigger()
                //指定任务名称
                .withIdentity("修改还款状态","RepayGroup")
                //绑定工作任务
                .forJob(jobDetail())
                //每隔5秒执行一job
                .withSchedule(CronScheduleBuilder.cronSchedule("10 1 0 * * ?"))
                .build();
    }


}
